'''
    1.投资模块相关的接口请求方法的封装
'''
import app


class TenderApi:

    def __init__(self, session):
        # 获取session对象
        self.session = session
        self.url_tender = app.BASE_HOST + "/trust/trust/tender"
        self.url_tender_list = app.BASE_HOST + "/loan/tender/mytenderlist"

    # 投资接口
    def tender(self, borrow_id, amount):
        # 定义一个变量，用来接收请求体的数据
        data_form = {"id": borrow_id, "depositCertificate": -1, "amount": amount}
        return self.session.post(url=self.url_tender, data=data_form)

    # 第三方投资接口
    def third_tender(self, url, data_dict):
        return self.session.post(url=url, data=data_dict)

    # 我的投资列表接口
    def user_tender_list(self, page, status):
        # 定义一个变量，用来接收请求体的数据
        data_form = {"page": page, "status": status}
        return self.session.post(url=self.url_tender_list, data=data_form)

    def user_tender_list_body(self, data_dict):
        return self.session.post(url=self.url_tender_list, data=data_dict)
